<script type="text/javascript">
function menuDelete(id){
	
	if(confirm("Are you sure ?")){
		
	document.location="?delmenu="+id;
	
	}
}

function duyuruDelete(id){
	
	if(confirm("Are you sure ?")){
		
	document.location="?delduy="+id;
	
	}
}
</script>
<?php
		if(strlen($_SESSION["user"])&& $_SESSION["level"]==2){
			if(strlen($_GET["delmenu"])!=0){
				mysql_query("delete from tbl_menu where menu_id='".$_GET["delmenu"]."'");
			}
			else if(strlen($_GET["delduy"])!=0){
				mysql_query("delete from tbl_duyuru where d_id='".$_GET["delduy"]."'");
			}
			
		}
		
		
?>

<?php // include_once("connection.php");?>
<div class="wrap">
				<div class="top">
				<div class="btm">
					<ul>
                    <li><?php if(strlen($_SESSION["user"])){ ?>
                    		
							<h3>Welcome <?php echo $_SESSION["name"]; ?></h3> 
							<ul><li>
							<div align="right"><input type="button" style="margin:10px;"  value="SIGN OUT" onclick="document.location='index.php?melih=false'"></div>
                            </li></ul>
                            <?php } 
                            else{?><h2>LOGIN </h2>
                                        <form action="index.php" method="post">
                                        <table style="color:black;">
                                        <tr>
                                            <td><label  for="username">Kullanici Adi</label></td>
                                            <td><input type="text" name="username" title="username" value="" /></td>
                                        </tr>
                                         <tr>
                                             <td><label for="">Password</label></td>
                                             <td><input type="password" name="password" title="password" value=""/></td>
                                         </tr>
                                         <tr ><td colspan="2" align="right"><input type="submit" name="login" title="login" value="login" /></td></tr>
                                        </table>
                                        </form>
							<?php } ?>
                             
						</li>
						<li>
							<h2>Menu</h2>
							<ul>
								<?php 
								$tablo=mysql_query("select * from tbl_menu order by menu_id");
								while($row=mysql_fetch_assoc($tablo)){
									if($row["valid"]==1){
									?>
                                    <li ><a href="<?php echo $row["link"];?>"><?php echo $row["title"];?> </a>&nbsp;&nbsp;<?php if(strlen($_SESSION["user"])&& $_SESSION["level"]==2){ ?><a href="#" onclick="menuDelete('<?php echo $row["menu_id"]; ?>');"><img src="images/delete.png" border="0" height="16" width="16" title="Delete"/></a><?php }?></li><?php 
									}
								}
								?>
							</ul>
                          <?php if(strlen($_SESSION["user"])&& $_SESSION["level"]==2){ ?><div align="right"> <a  href="addmenu.php" style="color:red;"><img width="20" height="20" src="images/add.png"/>add menu item</a></div><?php }?>
						</li>
						<li>
							<h2>Duyurular</h2>
                                                <marquee onmouseover=this.stop() onmouseout=this.start() scrollamount="2" scrolldlay="98" direction="up" width="176" height="100" align="center">
							<ul>
                            <?php 
								$tablo=mysql_query("select * from tbl_duyuru order by d_id");
								while($row=mysql_fetch_assoc($tablo)){
									?>
                                    <li ><a href="duyuru.php?duyuru=<?php echo $row["d_id"];?>"><?php echo $row["d_title"];?> </a>&nbsp;&nbsp;<?php if(strlen($_SESSION["user"])&& $_SESSION["level"]==2){ ?><a href="#" onclick="duyuruDelete('<?php echo $row["d_id"]; ?>');"><img src="images/delete.png" border="0" height="16" width="16" title="Delete"/></a><?php }?></li><?php 
									
								}
								?>
							</ul>
                                                </marquee>
                            <?php if(strlen($_SESSION["user"])&& $_SESSION["level"]==2){ ?><div align="right"> <a  href="duyadd.php" style="color:red;"><img width="20" height="20" src="images/add.png"/>add announcement</a></div><?php }?>
						</li>
						<li>
                        <?php $item=mysql_query("select * from tbl_menuitem");
							while($row=mysql_fetch_assoc($item)){ ?>
							<h2><?php echo $row["title"]; ?></h2>
							<ul>
                            <?php $sub=mysql_query("select * from tbl_subitem where item_id='".$row["item_id"]."'");
								while($subitems=mysql_fetch_assoc($sub)){ ?>
								<li>
									<a href="<?php echo $subitems["link"];?>"><?php echo $subitems["text"];?></a>
                                </li>
                                <?php } ?>
							</ul>
                            <?php } ?>
						</li><?php if(strlen($_SESSION["user"])&& $_SESSION["level"]==2){ ?>
                      <li> <div align="right"><a  href="addsitebar.php" ><img src="images/plus.png" border="0" height="16" width="16"/>Add Menu Item</a></div></li><?php }?>
					</ul>
				</div>
				</div>
				</div>